#ifndef LEVELEDITOR_H
#define LEVELEDITOR_H

#include <QWidget>
#include <QListWidget>
#include "texturemanager.h"
#include "objectmanager.h"
#include "animationmanager.h"

#ifdef WIN32
# define PATH_SLASH '\\'
#else
# define PATH_SLASH '/'
#endif

namespace Ui {
class LevelEditor;
}

class LevelEditor : public QWidget
{
    Q_OBJECT
    
public:
    explicit LevelEditor(QWidget *parent = 0);
    ~LevelEditor();

    void Save(const QString& filepath);
    bool Load(const QString& name, const QString& filepath);
    void Test(const QString& workdir);

public slots:
    void TextureAdded(QString);

private slots:
    void LoadTextures(void);
    void LoadAnimations(void);
    void LoadObjects(void);

    void PickNewTexture(void);
    void DeleteTexture(void);
    void TextureDeleted(QString);
    void TextureListIndexChanged(int);
    void TextureListUpdated(void);

    void CreateNewAnimation(void);
    void DeleteAnimation(void);
    void AnimationDeleted(QString);
    void AddAnimationToList(QString);

    void ObjectListIndexChanged(int);
    void CreateNewObject(void);
    void ObjectListUpdated(void);

    void LandscapeChanged(QString);
    void UpdateLevelSize(void);
    void AddEntity(void);
    void DelEntity(void);

private:
    static void      RemoveItemFromList(QListWidget* list, QString name);

    Ui::LevelEditor  *ui;
    TextureManager   _textureManager;
    ObjectManager    _objectManager;
    AnimationManager _animationManager;
    QString          _currentLevel;
    QString          _levelPath;
};

#endif // LEVELEDITOR_H
